export default class LocalStorageUtil {
    // 设置存储项
    static setItem(key, value) {
        if (typeof value === 'object') {
            value = JSON.stringify(value);
        }
        window.localStorage.setItem(key, value);
    }

    // 获取存储项
    static getItem(key) {
        let value = window.localStorage.getItem(key);
        if (value && (value.startsWith('{') || value.startsWith('['))) {
            value = JSON.parse(value);
        }
        return value;
    }

    // 删除存储项
    static removeItem(key) {
        window.localStorage.removeItem(key);
    }

    // 清除所有存储
    static clear() {
        window.localStorage.clear();
    }
}
// const localStorageUtil = new LocalStorageUtil()
// export default LocalStorageUtil